interface ChartData {
  x: string[];
  y: number[];
  avg: number[];
}

function getOption(data: ChartData) {
  const option = {
    // Make gradient line here
    visualMap: [
      {
        show: false,
        type: "continuous",
        seriesIndex: 0,
        min: 0,
        max: 400,
      },
      {
        show: false,
        type: "continuous",
        seriesIndex: 1,
        dimension: 0,
        min: 0,
        max: data.x.length - 1,
      },
    ],
    title: [
      {
        left: "center",
        text: "平均奖励",
      },
      {
        top: "48%",
        left: "center",
        text: "奖励函数",
      },
    ],
    tooltip: {
      trigger: "axis",
    },
    xAxis: [
      {
        data: data.x,
      },
      {
        data: data.x,
        gridIndex: 1,
      },
    ],
    yAxis: [
      {},
      {
        gridIndex: 1,
      },
    ],
    grid: [
      {
        bottom: "60%",
      },
      {
        top: "60%",
      },
    ],
    series: [
      {
        type: "line",
        showSymbol: false,
        data: data.avg,
      },
      {
        type: "line",
        showSymbol: false,
        data: data.y,
        xAxisIndex: 1,
        yAxisIndex: 1,
      },
    ],
  };
  return option;
}

export { getOption };
export type { ChartData };
